home *** CD-ROM | disk | FTP | other *** search
- unit Cpfile;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls;
-
- type
- TForm1 = class(TForm)
- Edit1: TEdit;
- Button1: TButton;
- Button2: TButton;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
- i: comp;
-
- implementation
-
- {$R *.DFM}
-
- uses LZExpand;
-
- procedure CopyFile(Source, Dest: String);
- var
- SourceHand, DestHand: Integer;
- OpenBuf: TOFStruct;
- begin
- { Place null-terminators at the end of the strings, so we can emulate a }
- { PChar. Note that (for safety) this will truncate a string if it is }
- { 255 characters long, but that's beyond the DOS filename limit anyway. }
- if Source[0] = #255 then
- Source[0] := #254
- Source[Ord(Source[0]) + 1] := #0;
- Dest[Ord(Dest[0]) + 1] := #0;
- { Open source file, and pass our psuedo-PChar as the filename }
- SourceHand := LZOpenFile(@Source[1], OpenBuf, of_Share_Deny_Write or of_Read);
- { raise an exception on error }
- if SourceHand = -1 then
- raise EInOutError.Create('Error opening source file');
- { Open destination file, and pass our psuedo-PChar as the filename }
- DestHand := LZOpenFile(@Dest[1], OpenBuf, of_Share_Exclusive or of_Write
- or of_Create);
- { close source and raise exception on error }
- if DestHand = -1 then begin
- LZClose(SourceHand);
- raise EInOutError.Create('Error opening destination file');
- end;
- try
- { copy source to dest, raise exception on error }
- if LZCopy(SourceHand, DestHand) < 0 then
- raise EInOutError.Create('Error copying file');
- finally
- { whether or not an exception occurs, we need to close the files }
- LZClose(SourceHand);
- LZClose(DestHand);
- end;
- end;
-
-
-
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- Edit1.Text := IntToStr(SizeOf(i));
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- CopyFile('c:\temp.exe', 'c:\xxx.exe');
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- var
- l: double;
- begin
- l := 3.5995044332;
- Edit1.Text := IntToStr(Round(l));
- end;
-
- end.
-